var async = require("async");
var renderEngin = require("../common/renderEngin");
var Tools = require("../common/tools");
var date = require("../common/date");
exports.order_manage = function (req, res) {
    use(["public/javascripts/order_manage/init.js", "public/javascripts/service/order_manageService.js"], function (PageComponent, order_manageService) {
        var storage = {};
        storage["slider"] = Tools.getPageSliderData("user_center");
        var beginDate = new Date().getBeforeDate(6) + ' 00:00:00',
            endDate = new Date().format("yyyy-MM-dd 23:59:59");
        order_manageService.search({
            headers: req.headers,
            urlParams: {
                startEffectTime: beginDate,
                endEffectTime: endDate,
                orderStatus: 'DRAFT',
                sort: 'createTime',
                asc: false,
                pageIndex: 1,
                pageSize: 10
            }
        }, function (result) {
            if (result.errorCode == 0) {
                storage['list'] = result.data;
                storage['total'] = result.pagination.totalResult;
            } else {
                storage['list'] = [];
                storage['total'] = 0;
            }
            PageComponent = React.createFactory(PageComponent);
            renderEngin.call(res, 'order_manage', PageComponent, storage);
        });
    });
}